#include "OperateForm.h"

OperateForm::OperateForm(QWidget *parent) : QDialog(parent)
{
    ui.setupUi(this);

    function = false;

    setOperations();
    createConnections();
}

OperateForm::~OperateForm()
{
    //dtor
}

void OperateForm::setOperations()
{
    ui.cbxOperation->insertItem(0,"Addition");
    ui.cbxOperation->insertItem(1,"Subtract");
    ui.cbxOperation->insertItem(2,"Multiply");
    ui.cbxOperation->insertItem(3,"Divide");
    ui.cbxOperation->insertItem(4,"sin(x)");
    ui.cbxOperation->insertItem(5,"cos(x)");
    ui.cbxOperation->insertItem(6,"tan(x)");
    ui.cbxOperation->insertItem(7,"exp(x)");
    ui.cbxOperation->insertItem(8,"ln(1+x)");
    ui.cbxOperation->insertItem(9,"log10(1+x)");
    ui.cbxOperation->insertItem(10,"x mod M");
}

void OperateForm::updateComboBoxStates(const QString &selectedOp)
{
    if(selectedOp == "Addition" || selectedOp == "Subtract" || selectedOp == "Multiply" || selectedOp == "Divide")
    {
        ui.cbxDataSource2->setDisabled(false);
        function = false;
    }
    else
    {
        ui.cbxDataSource2->setDisabled(true);
        function = true;
    }
}

void OperateForm::createConnections()
{
    connect(ui.cbxOperation, SIGNAL(activated(const QString &)), this, SLOT(updateComboBoxStates(const QString &)));
}
